﻿using System;
using System.IO;

namespace LocalSend2 {

	/// <summary>
	/// 共享的文件
	/// </summary>
	internal class ShareFile {

		static int IdCount = 1; // ID计数

		/// <summary>
		/// 文件ID
		/// </summary>
		public int ID = IdCount++;

		/// <summary>
		/// 本地文件的完整路径
		/// </summary>
		public string FullName;

		/// <summary>
		/// 文件名
		/// </summary>
		public string Name;

		/// <summary>
		/// 大小，字节
		/// </summary>
		public long Length;

		/// <summary>
		/// 最后修改时间
		/// </summary>
		public DateTime LastWriteTime;

		/// <summary>
		/// 显示名字
		/// </summary>
		public string DisplayName => "(" + ID + ")" + Name + (Length == 0 ? " [已删除]" : "");

		/// <summary>
		/// 可用于传输的文件信息
		/// </summary>
		public string FileInfoStr { get { return ID + "|" + Length + "|" + Name; } }

		/// <summary>
		/// 更新文件信息
		/// </summary>
		public void UpdateInfo(FileInfo fileInfo) {
			Name = fileInfo.Name;
			FullName = fileInfo.FullName;
			Length = fileInfo.Length;
			LastWriteTime = fileInfo.LastWriteTime;
		}
	}
}
